/* Copyright 2002 -- Ira R. Forman and Nate Forman */ 
/**
 * This is the base class for transformations that produce classes without
 * an input class.  By convention, such transformations hava a name of the 
 * form "Null2*C". This class provides
 * the implementation for the argument processing for all transformations.
 * These arguments are:<ul>
 * <li>-final -- indicates that the generated class must be final
 * <li>-notpublic -- the generated class must have package visability
 * <li>-abstract -- the generated class must be abstract
 * <li>-import xxxxx -- an import statement is generated for xxxxx
 *                     (this flag may be used multiple times)
 * <li>-interface -- the generated code is an interface instead of a class
 * <li>-package yyyyy -- the generated class is to be in the package yyyyy
 * <li>-output zzzzz -- the name of the generated class is to be zzzzz
 * </ul>
 * This class contins base implementations for all of the cooperative methods of the framework.
 *
 * In addition, this class is the base class for C2CTransformation, which is the 
 * the base class for all transformations that require an input class.
 */
//start extract C2CConstructor
package c2c;
import mopex.UQueue;

public abstract class C2CConstructor extends C2C {
    
    private   UQueue  cmdLineImports;

    protected String generateFlags() {                                 //#1
	return "[-notpublic] [-final] [-abstract] "                    //#1
	       + "[[-import name]...] [-package name] [-output name]"; //#1
    }

    protected String generateClassNamePrefix() { return ""; }

    protected void checkAndProcessArgs( Args args ) {

	outputClassName = args.getFlagValue( "-output" );
	if ( outputClassName == null )
	    if ( inputClassName == null ) {
		throw new C2CException( "no output class name");
	    } else {
		outputClassName = classNamePrefix + inputClassName;    //#2
	    }

	packageName = args.getFlagValue( "-package" );                 //#3
	if ( packageName == null )                                     //#3
	    qualifiedOutputClassName = outputClassName;                //#3
	else                                                           //#3
	    qualifiedOutputClassName                                   //#3
		= packageName + "." + outputClassName;                 //#3

	isNotPublic = args.hasFlag( "-notpublic" );                    //#4
	isFinal = args.hasFlag( "-final" );                            //#4
	isInterface = args.hasFlag( "-interface" );                    //#4
	isAbstract = args.hasFlag( "-abstract" );                      //#4

	cmdLineImports = args.getFlagValues( "-import" );              //#5

	if ( outputClassName.equals( inputClassName ) )
	    throw new C2CException("outputClassName = inputClassName");
    }

    protected UQueue         generateImports() {return cmdLineImports;}
    protected String         getClassLevelJavadoc() {return "";}
    protected String         getSuperclass() {return "";}
    protected UQueue         generateInterfaces() {
	return new UQueue(String.class);
    }
    protected String         generateFields() {return "";}
    protected String         generateConstructors() {return "";}
    protected String         generateMethods() {return "";}
    protected String         generateNestedClasses() {return "";}
    protected void           checkPostconditions() {}
}
//stop extract C2CConstructor
